<template>
  <div class="task-design-page">
    <el-card class="design-card">
      <template #header>
        <div class="card-header">
          <span>任务设计</span>
          <el-button type="primary" @click="handleDesign" v-if="hasPerm('task:design:design')">设计任务</el-button>
        </div>
      </template>
      
      <el-table :data="designList" style="width: 100%">
        <el-table-column prop="taskCode" label="任务编号" width="120" />
        <el-table-column prop="taskName" label="任务名称" width="200" />
        <el-table-column prop="designer" label="设计人" width="100" />
        <el-table-column prop="designDate" label="设计日期" width="120" />
        <el-table-column prop="status" label="状态" width="100">
          <template #default="scope">
            <el-tag type="info">设计中</el-tag>
          </template>
        </el-table-column>
        <el-table-column label="操作" width="150">
          <template #default="scope">
            <el-button size="small" @click="handleView(scope.row)" v-if="hasPerm('task:design:view')">查看</el-button>
            <el-button size="small" type="primary" @click="handleEdit(scope.row)" v-if="hasPerm('task:design:edit')">编辑</el-button>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>

<script setup>
import { ref, onMounted } from 'vue'
import { hasPerm } from '@/utils/permission'
import { ElMessage } from 'element-plus'

const designList = ref([])

const handleDesign = () => {
  ElMessage.info('设计任务功能')
}

const handleView = (row) => {
  ElMessage.info(`查看设计：${row.taskCode}`)
}

const handleEdit = (row) => {
  ElMessage.info(`编辑设计：${row.taskCode}`)
}

onMounted(() => {
  // 模拟数据
  designList.value = [
    {
      taskCode: 'TASK001',
      taskName: '需求分析',
      designer: '张三',
      designDate: '2025-07-20',
      status: 'designing'
    },
    {
      taskCode: 'TASK002',
      taskName: '系统设计',
      designer: '李四',
      designDate: '2025-07-22',
      status: 'designing'
    }
  ]
})
</script>

<style scoped>
.task-design-page {
  padding: 20px;
}

.design-card {
  margin-bottom: 20px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
</style> 